<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>getter和setter属性设置</title>
</head>
<body>
<script>
    // get 和 set
    class Phone{
        get price(){
            console.log('价格被已被读取！！')
            return 5299
        }
        set price(newValue){
            console.log('价格已被修改！！')
            console.log(newValue)//输出修改后的价格
        }
    }
    //实例化对象
    let phone=new Phone();
    console.log(phone.price)//输出原来的价格
    phone.price=20//修改价格
</script>
</body>
</html>